import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import { productid } from '../../atom/config';
import refresh from '@dfeidao/atom-web/url/refresh';
import error from '@dfeidao/atom-web/msgbox/error';

export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// todo
	const res1 = await nodejs<{ re: string }>("test-web/zj-000004/s003", "");
	const creatime = new Date().getTime();
	const re = res1;


	const assetsname = fd.data.node.querySelector<HTMLSelectElement>("[data-id='assetsname']").value;
	const place = fd.data.node.querySelector<HTMLSelectElement>("[data-id='place']").value;
	const working_hours = fd.data.node.querySelector<HTMLSelectElement>("[data-id='working_hours']").value;
	const cust_name = fd.data.node.querySelector<HTMLSelectElement>("[data-id='cust_name']").value;
	const contact_number = fd.data.node.querySelector<HTMLSelectElement>("[data-id='contact_number']").value;
	const source_type = fd.data.node.querySelector<HTMLSelectElement>("[data-id='source_type']").value;
	const job_content = fd.data.node.querySelector<HTMLSelectElement>("[data-id='job_content']").value;
	const dyremindtime = fd.data.node.querySelector<HTMLSelectElement>("[data-id='dyremindtime']").value;
	const project_no = fd.data.node.querySelector<HTMLSelectElement>("[data-id='project_no']").value;
	const work_order_status = fd.data.node.querySelector<HTMLSelectElement>("[data-id='work_order_status']").value;
	console.log("work_order_status",work_order_status);
	console.log("source_type",source_type);
if(!assetsname||!place||!working_hours||!contact_number||!source_type||!job_content||!dyremindtime||!project_no){
		error("请完善数据");
		return;
}
const reg = new RegExp("^[0-9]*$");
	if(!reg.test(contact_number)){  
		error("请输入数字!"); 
		return;
    }
	const res = await nodejs<{ code: 0 | 1; reslut: string }>("test-web/zj-000004/s002", {
		filter: {
			productid,
			project_no,
			work_bill_no: re,
			work_order_status:work_order_status,
			assetsname: assetsname,
			place: place,
			working_hours: working_hours,
			cust_name: cust_name,
			contact_number: contact_number,
			source_type: source_type,
			job_content: job_content,
			dyremindtime: dyremindtime,
			create_time: creatime
		}
	});
	if (res.code == 1) {
		alert("添加成功");
		refresh();
	} else {
		alert("添加失败");
	}



}
